IF EXISTS (SELECT *
           FROM INFORMATION_SCHEMA.ROUTINES
           WHERE ROUTINE_NAME='pInOutProductPaper_Delete'
           AND ROUTINE_SCHEMA='dbo'
           AND ROUTINE_TYPE='PROCEDURE'
          )
          DROP PROCEDURE dbo.pInOutProductPaper_Delete
GO

CREATE PROC dbo.pInOutProductPaper_Delete
	@id  AS INT
AS

	IF (NOT EXISTS(SELECT 1 FROM dbo.InOutProdDetail WHERE InOutProdPaperId = @id))
	 BEGIN
		 DELETE FROM  dbo.InOutProdPaper
		 WHERE Id = @id
	END